<template>
  <div class="wfull">
    <a-form :labelCol="{ span: 6 }" :wrapperCol="{ span: 18 }">
      <a-form-item label="流程名称" :required="true">
        <ZgInput v-model="obj.name"></ZgInput>
      </a-form-item>
      <a-form-item label="流程类型" :required="true">
        <ZgDictionary v-model="obj.type" code="flowType"></ZgDictionary>
      </a-form-item>
      <a-form-item label="流程分类" :required="true">
        <ZgDictionary v-model="obj.category" code="flowCategory"></ZgDictionary>
      </a-form-item>
      <a-form-item label="后续流程编号">
        <ZgInput v-model="obj.nextCode"></ZgInput>
      </a-form-item>
    </a-form>
  </div>
</template>
<script>
import { dic } from './dic'
export default {
  props: {
      jsonStr: {
          type: String,
          default: null
      }
  },
  data () {
    return {
      dic,
      obj: {
        name: '',
        type: '',
        category: '',
        nextCode: '',
        id: '0'
      }
    }
  },
  watch: {
    jsonStr () {
      this.init()
    }
  },
  mounted () {
    this.init()
  },
  methods: {
    init () {
      if (this.jsonStr && this.jsonStr.length > 0) {
        const json = JSON.parse(this.jsonStr)
        this.obj = Object.assign({}, json)
      }
    },
    save () {
      if (this.obj.name.length === 0) {
        return this.$result.error('请输入流程名称')
      }
      if (this.obj.type.length === 0) {
        return this.$result.error('请输入流程类型')
      }
      if (this.obj.category.length === 0) {
        return this.$result.error('请输入流程分类')
      }
      if (this.obj.nextCode.length === 0) {
        return this.$result.error('请输入后续流程编号')
      }
      return this.$result.ok(Object.assign({}, this.obj))
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
